<template>
  <div>
    <div class="breadcrumb">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>系统管理</el-breadcrumb-item>
        <el-breadcrumb-item>app设置</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-card>
      <el-form ref="editFormRef" :model="info" label-width="120px">
        <el-form-item label="警示信息:">
          <el-input
            type="textarea"
            v-model="info.warning"
            style="width: 500px"
          ></el-input>
        </el-form-item>
        <el-form-item label="租机指南:">
          <ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
        </el-form-item>
        <el-form-item>
          <el-button class="btnprimary" @click="save">保存</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script>
   import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
export default {
  name: "appset",
  data() {
    return {
      info: {
        id: "1",
        warning: "",
        editor: ClassicEditor,
        editorData: '<p>Content of the editor.</p>',
        editorConfig: {
                    // The configuration of the editor.
                }
      },
    };
  },
  created() {
      this.init();
  },
  methods: {
    async init() {
          const loading = this.$loading({
                lock: true,
                text: "Loading",
                spinner: "el-icon-loading",
                background: "rgba(0, 0, 0, 0.7)",
            });
     	const {data:res} = await this.$http.post("/set/getAppSet?id="+this.info.id, { });
        this.info.warning = res.data.warning
        
      setTimeout(() => {
        loading.close();
      }, 500);
    },
    async save() {
         const loading = this.$loading({
                lock: true,
                text: "Loading",
                spinner: "el-icon-loading",
                background: "rgba(0, 0, 0, 0.7)",
            });
        const {data:res} = await this.$http.post("/set/updateAppSet", this.info);
		this.$message.success('设置成功');
         setTimeout(() => {
            loading.close();
        }, 500);
    },
  },
};
</script>

<style>
</style>